SET(LIB_POSTFIX "_x86.lib")
IF(WIN32)
    IF(CMAKE_CL_64)
        SET(LIB_POSTFIX "_x64.lib")
    ENDIF(CMAKE_CL_64)
ELSE()
    IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
        SET(LIB_POSTFIX "_x64.a")
    ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
ENDIF()

FIND_PATH(NVFLEX_INCLUDE_DIR flex.h)
FIND_PATH(NVFLEX_LIB_DIR flexRelease${LIB_POSTFIX})

IF(WIN32 AND NVFLEX_INCLUDE_DIR AND NVFLEX_LIB_DIR)
    LINK_DIRECTORIES(${NVFLEX_LIB_DIR})
    SET(EXTERNAL_INCLUDE_DIR ${NVFLEX_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
    SET(EXTERNAL_LIBRARIES ${OPENGL_LIBRARIES}
        debug flexDebug${LIB_POSTFIX} optimized flexRelease${LIB_POSTFIX})
    
    SET(EXAMPLE_NAME osgflex)
    SET(EXAMPLE_FILES osgflex.cpp FlexDrawable.cpp)
    START_EXAMPLE()
ENDIF(WIN32 AND NVFLEX_INCLUDE_DIR AND NVFLEX_LIB_DIR)
